﻿Imports Phila
Imports Phila.Sql
Imports Phila.CommonClasses
Imports Telerik.WebControls

Public Class ViewRoomCategory
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        'Dim strSql As String
        'strSql = "select * from ptn_RoomCategory order by Id desc"
        'Fill_Grid_Bind(gvRoomCat, strSql)
    End Sub

    Protected Sub radGrid_DeleteCommand(ByVal source As Object, ByVal e As Telerik.WebControls.GridCommandEventArgs) Handles RadGrid.DeleteCommand
        Dim ID As String = (CType(e.Item, GridDataItem)).OwnerTableView.DataKeyValues(e.Item.ItemIndex)("ID").ToString
        Try
            Dim txt As Array
            txt = RetriveData("select Id from ptn_roomCategory where id in" & ID, 0)
            If txt(0) Is Nothing Then
                Insert_Update_Delete_Record("delete from ptn_Category where id=" & ID)
            Else
                'radGrid.Controls.Add(New LiteralControl(("Unable to Delete Record. Reason: Some tours belonging this category")))
                lblMsg.Text = "Unable to Delete Record. Reason: Some tours belonging this category"
                lblMsg.ForeColor = Drawing.Color.Red
            End If
        Catch ex As Exception
            'radGrid.Controls.Add(New LiteralControl(("Unable to Delete Record. Reason: " + ex.Message)))
            lblMsg.Text = "Unable to Delete Record. Reason: " + ex.Message
            lblMsg.ForeColor = Drawing.Color.Red
            e.Canceled = True
        End Try
    End Sub

    Protected Sub radGrid_NeedDataSource(ByVal source As Object, ByVal e As Telerik.WebControls.GridNeedDataSourceEventArgs) Handles RadGrid.NeedDataSource
        Fill_Grid(RadGrid, "select * from ptn_RoomCategory order by Name")
    End Sub

End Class